﻿<UserControl x:Class="GameOfLife.Controls.Toolbox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
    xmlns:local="clr-namespace:GameOfLife.Controls"
    Width="400" Height="300">
    <UserControl.Resources>
        <local:DataListProvider x:Key="DataProvider" />
        <local:ColorTypeConverter x:Key="ColorConveter" />
        <local:ConnectionTypeConverter x:Key="ConnectionConveter" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFF3F7FA" Offset="0"/>
                <GradientStop Color="#FFFFFFFF" Offset="0.1"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="{Binding Path=Strings.ToolBoxHeader, Source={StaticResource LocalizationString}}" Style="{StaticResource ToolBoxHeaderStyle}" />

        <StackPanel Grid.Row="1"  Style="{StaticResource ToolBoxRowStyle}">
            <TextBlock Text="{Binding Path=Strings.ColumnsLabel, Source={StaticResource LocalizationString}}"  Style="{StaticResource ToolBoxTextBoxStyle}" />
            <TextBox x:Name="Columns" Width="50" Text="{Binding Columns, Mode=TwoWay}" />
            <dataInput:DescriptionViewer  Description="{Binding Path=Strings.ColumnsDescription, Source={StaticResource LocalizationString}}" />
        </StackPanel>

        <StackPanel Grid.Row="2" Style="{StaticResource ToolBoxRowStyle}">
            <TextBlock Text="{Binding Path=Strings.RowsLabel, Source={StaticResource LocalizationString}}"  Style="{StaticResource ToolBoxTextBoxStyle}" />
            <TextBox x:Name="Rows" Width="50" Text="{Binding Rows, Mode=TwoWay}" />
            <dataInput:DescriptionViewer Description="{Binding Path=Strings.RowsDescription, Source={StaticResource LocalizationString}}" />
        </StackPanel>

        <StackPanel Grid.Row="3" Style="{StaticResource ToolBoxRowStyle}">
            <TextBlock Text="{Binding Path=Strings.RuleLabel, Source={StaticResource LocalizationString}}"  Style="{StaticResource ToolBoxTextBoxStyle}" />
            <TextBox x:Name="Rule" Width="150" Text="{Binding Rule, Mode=TwoWay}" />
            <dataInput:DescriptionViewer Description="{Binding Path=Strings.RuleDescription, Source={StaticResource LocalizationString}}" />
        </StackPanel>

        <StackPanel Grid.Row="4" Style="{StaticResource ToolBoxRowStyle}">
            <TextBlock Text="{Binding Path=Strings.ConnectionTypeModeLabel, Source={StaticResource LocalizationString}}"  Style="{StaticResource ToolBoxTextBoxStyle}" />
            <ComboBox x:Name="ConnectionTypeList" ItemsSource="{Binding ConnectionList,Source={StaticResource DataProvider}}" DisplayMemberPath="Name"  SelectedItem="{Binding ConnectionType, Mode=TwoWay, Converter={StaticResource ConnectionConveter}}" SelectionChanged="ConnectionTypeListSelectionChanged" />
            <dataInput:DescriptionViewer Description="{Binding Path=Strings.ConnectionTypeDescription, Source={StaticResource LocalizationString}}" />
        </StackPanel>

        <StackPanel Grid.Row="5" Style="{StaticResource ToolBoxRowStyle}">
            <TextBlock Text="{Binding Path=Strings.ColoringModeLabel, Source={StaticResource LocalizationString}}"  Style="{StaticResource ToolBoxTextBoxStyle}" />
            <ComboBox x:Name="ColorList" ItemsSource="{Binding ColorList,Source={StaticResource DataProvider}}" DisplayMemberPath="Name"  SelectedItem="{Binding ColoringMode, Mode=TwoWay, Converter={StaticResource ColorConveter}}" SelectionChanged="ColorListSelectionChanged" />
        </StackPanel>
        
        <StackPanel Grid.Row="6" Style="{StaticResource ToolBoxRowStyle}">
            <TextBlock Text="{Binding Path=Strings.TimerSetting, Source={StaticResource LocalizationString}}" Style="{StaticResource ToolBoxTextBoxStyle}" />
            <Slider Minimum="100"  Maximum="1000" SmallChange="100"  Width="150" Height="20" Value="{Binding TimerStep,Mode=TwoWay}" ValueChanged="SliderValueChanged"  />
        </StackPanel>

        <StackPanel  Grid.Row="7" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button x:Name="PrepareButton" Click="CreateButtonClick" Content="{Binding Path=Strings.PrepareButton, Source={StaticResource LocalizationString}}" Style="{StaticResource ToolBoxButton}"/>
            <Button x:Name="RandomButton" Click="RandomButtonClick" Content="{Binding Path=Strings.RandomButton, Source={StaticResource LocalizationString}}" Style="{StaticResource ToolBoxButton}" />            
        </StackPanel>
    </Grid>

</UserControl>
